package com.sheep.api.hive.dao.impl;

import com.sheep.api.hive.dao.HiveCommonDao;
import com.sheep.api.hive.dao.LocalHiveOperations;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 16-4-25
 * Time: 下午3:09
 * To change this template use File | Settings | File Templates.
 */
@Repository
public class HiveCommonByOperationsDaoImpl extends LocalHiveOperations implements HiveCommonDao {
    @Override
    public void createTable() {
        getHiveOperations().query("classpath:hql/test.hql");
    }

    @Override
    public List<String> getAllTableRecord(String tableName) {
        HashMap<String,Object> map = new HashMap<String,Object>();
        map.put("tableName",tableName);
        return getHiveOperations().query("classpath:hql/table1.hql",map);
    }


    @Override
    public List<String> getTableRecord(String key, String tableName) {
        return getHiveOperations().query("select * from " + tableName + " where anfi = '" + key + "'");
    }
}
